# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=flashscanner
pkgver=11.6815b02
pkgrel=8
groups=('blackarch' 'blackarch-scanner' 'blackarch-webapp')
pkgdesc='Flash XSS Scanner.'
arch=('any')
url='https://github.com/riusksk/FlashScanner'
license=('custom:unknown')
depends=('perl' 'perl-uri' 'perl-libwww')
makedepends=('git')
source=("$pkgname::git+https://github.com/riusksk/FlashScanner.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  sed -i 's|# !/url/bin/perl -w|#!/usr/bin/perl -w|' FlashScanner.pl
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  rm README.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec perl FlashScanner.pl "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

